const state = {
  contentType: new Array(),
  contentTypeSelectModel: ''
}
const mutations = {
  SET_CONTENTTYPE: (state, data) => {
    try {
      for (let i = 0; i < state.contentType.length; i++) {
        if (state.contentType[i].id == data.id) {
            state.contentType.splice(i, 1)
        }
      }
    } catch (e) {
    }
      state.contentType.push(data)
  },
  SET_CONTENTTYPE_SELECT_MODEL: (state, data) => {
      state.contentTypeSelectModel=data
  },
  CLEAN_CONTENTTYPE: (state) => {
    state.contentType = new Array()
    state.contentTypeSelectModel=''
  },
  CLEAN_CONTENTTYPE_DATA: (state) => {
    state.contentType = new Array()
  }
}

const actions = {
  // 设置课程等级
  setContentType({ commit }, data) {
    commit('SET_CONTENTTYPE', data)
  },
  // 设置选择模式
  setContentTypeSelectModel({ commit }, data) {
    commit('SET_CONTENTTYPE_SELECT_MODEL', data)
  },
  // 清空代理-全部清空
  cleanContentType({ commit }) {
    commit('CLEAN_CONTENTTYPE')
  },
  // 清空代理-选中数据
  cleanContentTypeData({ commit }) {
    commit('CLEAN_CONTENTTYPE_DATA')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

